package com.ruoyi.common.config;

import lombok.Data;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 描述
 * 作者 ZhangPing
 * 创建时间 2023/9/5 19:18
 */
@Component
@ConfigurationProperties(prefix = "sim-card")
@Data
public class SimCardConfig {

    /** key */
    private String apiKey;
    /** secret */
    private String apiSecret;
    /** 接口URL */
    private String apiUrl;

    /**
     * 获取调用单个信息获取接口的url
     */
    public String getSingleUrl(String simId) {
        String sign = DigestUtils.md5Hex(apiSecret.getBytes());
        return apiUrl + apiKey + "/card/" + simId + "/?_sign=" + sign;
    }

    /**
     * 获取调用批量信息获取接口的url
     */
    public String getBatchUrl(String paramsJson) {
        String str = paramsJson + apiSecret;
        String sign = DigestUtils.md5Hex(str.getBytes());
        return apiUrl + apiKey + "/batch/card/info/?_sign=" + sign;
    }

}
